<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="test1"></div>
<div id="test2"></div>
<div id="test3"></div>

<script crossorigin src="https://unpkg.com/react@17/umd/react.development.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@17/umd/react-dom.development.js"></script>

<!-- jsx转为js -->
<script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script>

<script type="text/babel">

    class Person extends React.Component {
        render() {
            let {name, age, sex} = this.props
            return (
                    <ul>
                        <li>姓名：{this.props.name}</li>
                        <li>性别：{this.props.sex}</li>
                        <li>年龄：{age + 1}</li>
                    </ul>
            )
        }
    }

    // 渲染一次new 一次对象
    // props属性得到 {"name": "tom"}
    ReactDOM.render(<Person name="tom1" age={18} sex="女"/>, document.getElementById("test1"))
    ReactDOM.render(<Person name="tom2" age="18" sex="女"/>, document.getElementById("test2"))

    let p = {name:"姓名", age : 18, sex: "女"}
    // ReactDOM.render(<Person name={p.name} age={p.age} sex={p.sex}/>, document.getElementById("test3"))
    // 这个花括号是写js表达式，并不是 js 的对象解构{...p}
    ReactDOM.render(<Person {...p}/>, document.getElementById("test3"))



</script>
</body>
</html>